#ifndef PIPE2_H
#define PIPE2_H

#ifdef _WIN32
  #include <windows.h>
#else
  #include <unistd.h>
#endif
#include "bool.h"

const int LINE_INPUT_MAX_CHAR = 1024;

class Pipe2
{
public:
    Pipe2();

#ifdef _WIN32
    HANDLE hInput, hOutput;
    BOOL bConsole;
    int nBytesLeft;
    #else
    int nInput, nOutput;
#endif
    int nReadEnd;
    char szBuffer[LINE_INPUT_MAX_CHAR];

    void Open(const char *szExecFile = NULL);
    void Close(void) const;
    void ReadInput(void);
    Bool CheckInput(void);
    Bool GetBuffer(char *szLineStr);
    Bool LineInput(char *szLineStr);
    void LineOutput(const char *szLineStr) const;
};

#endif // PIPE2_H
